using Infrastructure.Attribute;
using Infrastructure.Extensions;
using JTZY.Model.Batch.Dto;
using JTZY.Model.Batch;
using JTZY.Repository;
using JTZY.Service.Batch.IBatchService;

namespace JTZY.Service.Batch
{
    /// <summary>
    /// 批量发货物码Service业务层处理
    /// </summary>
    [AppService(ServiceType = typeof(IBatchshipdetailService), ServiceLifetime = LifeTime.Transient)]
    public class BatchshipdetailService : BaseService<Batchshipdetail>, IBatchshipdetailService
    {
        /// <summary>
        /// 查询批量发货物码列表
        /// </summary>
        /// <param name="parm"></param>
        /// <returns></returns>
        public PagedInfo<BatchshipdetailDto> GetList(BatchshipdetailQueryDto parm)
        {
            var predicate = QueryExp(parm);

            var response = Queryable()
                .Where(predicate.ToExpression())
                .ToPage<Batchshipdetail, BatchshipdetailDto>(parm);

            return response;
        }


        /// <summary>
        /// 获取详情
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        public Batchshipdetail GetInfo(int Id)
        {
            var response = Queryable()
                .Where(x => x.ScanMode == Id)
                .First();

            return response;
        }

        /// <summary>
        /// 添加批量发货物码
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public Batchshipdetail AddBatchshipdetail(Batchshipdetail model)
        {
            return Insertable(model).ExecuteReturnEntity();
        }

        /// <summary>
        /// 修改批量发货物码
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public int UpdateBatchshipdetail(Batchshipdetail model)
        {
            return Update(model, true);
        }

        /// <summary>
        /// 查询导出表达式
        /// </summary>
        /// <param name="parm"></param>
        /// <returns></returns>
        private static Expressionable<Batchshipdetail> QueryExp(BatchshipdetailQueryDto parm)
        {
            var predicate = Expressionable.Create<Batchshipdetail>();

            return predicate;
        }
    }
}